package com.xiaoxin.lease.web.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoxin.lease.model.entity.PaymentType;
import com.xiaoxin.lease.model.entity.RoomPaymentType;
import com.xiaoxin.lease.web.admin.service.PaymentTypeService;
import com.xiaoxin.lease.web.admin.mapper.PaymentTypeMapper;
import com.xiaoxin.lease.web.admin.service.RoomPaymentTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author liubo
* @description 针对表【payment_type(支付方式表)】的数据库操作Service实现
* @createDate 2023-07-24 15:48:00
*/
@Service
public class PaymentTypeServiceImpl extends ServiceImpl<PaymentTypeMapper, PaymentType>
    implements PaymentTypeService{

    @Autowired
    RoomPaymentTypeService roomPaymentTypeService;
    @Override
    public List<PaymentType> selectPaymentTypeList(Long id) {
        List<PaymentType> paymentTypeList = new ArrayList<>();
        List<RoomPaymentType> roomPaymentTypeList = roomPaymentTypeService.list(new LambdaQueryWrapper<RoomPaymentType>().eq(RoomPaymentType::getRoomId,id));
        if(roomPaymentTypeList.size()>0){
            paymentTypeList = super.list(new LambdaQueryWrapper<PaymentType>().in(PaymentType::getId,roomPaymentTypeList.stream().map(f -> f.getPaymentTypeId()).toList()));
        }
        return paymentTypeList;
    }
}




